#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>

bool isPrime(int number) {
    if (number <= 1) return false;
    if (number <= 3) return true;

    if (number % 2 == 0 || number % 3 == 0) return false;

    for (int i = 5; i * i <= number; i += 6) {
        if (number % i == 0 || number % (i + 2) == 0) return false;
    }
    return true;
}

int main() {
    std::unordered_map<std::string, int> words_to_numbers = {
        {"zero", 0}, {"one", 1}, {"two", 2}, {"three", 3}, {"four", 4},
        {"five", 5}, {"six", 6}, {"seven", 7}, {"eight", 8}, {"nine", 9}
    };

    std::string input, word;
    std::vector<int> digits;
    int number = 0;

    std::getline(std::cin, input);
    std::istringstream iss(input);

    while (iss >> word) {
        if (words_to_numbers.find(word) == words_to_numbers.end()) {
            std::cout << "Wrong input";
            return 0;
        }
        digits.push_back(words_to_numbers[word]);
    }

    if (digits.size() != 3) {
        std::cout << "Wrong input";
        return 0;
    }

    number = digits[0] * 100 + digits[1] * 10 + digits[2];

    int closestPrime = number;
    while (!isPrime(closestPrime)) {
        closestPrime++;
    }

    std::cout << closestPrime;
    return 0;
}